package com.yx.elastic.elasticcm.orm;


/**
 * Created by chenzp on 18-8-1.
 */
public class ElasORMException extends RuntimeException {

    private int errorCode;

    private ElasORMExceptionCode code;

    public ElasORMException(int errorCode) {
        super(ElasORMExceptionCode.getNameByCode(errorCode));
        this.errorCode = errorCode;
    }


    public ElasORMException(ElasORMExceptionCode code) {
        super(code.getMessage());
        this.errorCode = code.getCode();
    }



    public ElasORMException(String message, ElasORMExceptionCode code) {
        super(code.getMessage()+" "+message);
        this.errorCode = code.getCode();
    }

    public ElasORMException(String message, int errorCode) {
        super(ElasORMExceptionCode.getNameByCode(errorCode)+" "+message);
        this.errorCode = errorCode;
    }

    public ElasORMException(String message, Throwable throwable, int errorCode) {
        super(ElasORMExceptionCode.getNameByCode(errorCode)+" "+message, throwable);
        this.errorCode = errorCode;
    }

    public ElasORMException(Throwable throwable, int errorCode) {
        super(throwable);
        this.errorCode = errorCode;
    }

    public ElasORMException(String message, Throwable throwable, boolean b, boolean b1, int errorCode) {
        super(ElasORMExceptionCode.getNameByCode(errorCode)+" "+message, throwable, b, b1);
        this.errorCode = errorCode;
    }

    public int getErrorCode() {
        return errorCode;
    }
}
